package cn.tedu.lucky.draw.server.repository;

import cn.tedu.lucky.draw.server.protocol.po.Activity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ActivityRepository extends JpaRepository<Activity,Long> {

    List<Activity> findByName(String name);

    List<Activity> findByIdBetween(Long start, Long end);

    List<Activity> findByNameAndStatusOrderBySort(String name, Integer status);

    /**
     * 根据活动名称和状态查询活动
     */
    Page<Activity> findByStatusAndEndTimeBefore(Integer status, LocalDateTime endTime, Pageable pageable);

    List<Activity> findByStatusEquals(Integer status);
}
